from urllib.request import Request, urlopen
from urllib.parse import urlencode
from fake_useragent import UserAgent

# url = "https://www.baidu.com/s?wd=%E6%B2%88%E7%83%81%E5%8D%8E"
# wd=沈烁华，沈烁华需要进行转码
args = {  # 里面有多个参数是会自动转码后加上&
    "wd": "沈烁华",
    # "ie":"utf-8"
}
# print(urlencode(args))
url = "https://www.baidu.com/s?{}".format(urlencode(args))
# print(url)
headers = {
    "User-Agent": UserAgent().random
}
request = Request(url, headers=headers)
response=urlopen(request)
info=response.read()
print(info.decode())